package com.atwisdom.star.serviceController.production;

import com.alibaba.fastjson.JSONObject;
import com.atwisdom.star.common.vo.ActionData;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.exception.pojo.BusinessException;
import com.atwisdom.star.log.aop.StarAnnotation;
import com.atwisdom.star.service.production.impl.StorehouseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: StorehouseServiceController
 * @ Description:
 * @author:王红艳
 * @date: 2024/05/30 15:36
 */
@RestController
@RequestMapping("/storehouse")
public class StorehouseServiceController {
    @Autowired
    private StorehouseServiceImpl storehouseServiceImpl;

    /**
     * 新增仓库
     * @param data 仓库数据
     * @return 仓库数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/addStorehouse")
    public ResultInfo<?> addStorehouse(@RequestBody JSONObject data)  throws BusinessException {
        return storehouseServiceImpl.addStorehouse(data);
    }

    /**
     * 更新仓库
     * @param data 仓库数据
     * @return 仓库数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/updateStorehouse")
    public ResultInfo<?> updateStorehouse(@RequestBody JSONObject data)  throws BusinessException {
        return storehouseServiceImpl.updateStorehouse(data);
    }

    /**
     * 删除仓库
     * @param data 仓库数据
     * @return 仓库数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/deleteStorehouse")
    public ResultInfo<?> deleteStorehouse(@RequestBody JSONObject data)  throws BusinessException {
        return storehouseServiceImpl.deleteStorehouse(data);
    }
    /**
     * 分页查询，过滤掉被占用的数据
     * @param actionData 分页查询参数
     * @return 分页数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/queryTankNotLinkByPage")
    public ResultInfo<?> queryTankNotLinkByPage(@RequestBody ActionData<JSONObject> actionData)  throws BusinessException {
        return storehouseServiceImpl.queryTankNotLinkByPage(actionData);
    }

    /**
     * 入库 库位编码，库位名称，storeJson,linkId为入库的桶的id
     * @param data 入库数据
     * @return hier更新后的json
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/inputBound")
    public ResultInfo<?> inputBound(@RequestBody JSONObject data)  throws BusinessException {
        return storehouseServiceImpl.inputBound(data);
    }
    /**
     * 出库 库位编码，库位名称,
     * @param data 出库数据
     * @return hier更新后的json
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/outBound")
    public ResultInfo<?> outBound(@RequestBody JSONObject data)  throws BusinessException {
        return storehouseServiceImpl.outBound(data);
    }

    /**
     * 根据hier数据查询下面的桶的数据
     * @param data
     * @return hier数据包含桶
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/queryTankById")
    public ResultInfo<?> queryTankById(@RequestBody JSONObject data)  throws BusinessException {
        return storehouseServiceImpl.queryTankById(data);
    }
}
